/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package scala.afei.drum;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.shapes.OvalShape;

/**
 * A data structure that holds a Shape and various properties that can be used to define
 * how the shape is drawn.
 */
public class ShapeHolder  {
    public int startX = 0, startY = 0, endX = 0, endY = 0;
    public Paint paint;

    public OvalShape ovalShape;
    public int duration;
    public long startTime;
    public int currentX = 0, currentY = 0;
    
    public ShapeHolder(OvalShape shape) {
    	this.ovalShape = shape;
    }
    
    public void logic() {
    	long deltaTime = System.currentTimeMillis() - startTime;
//    	currentX = (int) (((double) endX - startX) * deltaTime / duration);
    	currentX = (int) (endX + startX) /2;
    	currentY = (int) (((double) endY - startY) * deltaTime / duration) + startY;
    	System.out.println("currentX = " + currentX + " currentY = " + currentY);
    }
    
    public void draw(Canvas canvas) {
        canvas.save();
        canvas.translate(currentX, currentY);
        System.out.println(" y = " + currentY);
        ovalShape.draw(canvas, paint);
        canvas.restore();
    }
    
    public void setPaint(Paint value) {
        paint = value;
    }
    public Paint getPaint() {
        return paint;
    }
}
